clear all
close all
TSPAN = [0, 1];
Y0 = [0, 0];
tf=1;
options=odeset('refine',2)
[TOUT,YOUT] = ode23(@func,TSPAN,Y0,options);

fprintf('Final value of the objective function: %0.6f \n', YOUT(end,1))
N=length(YOUT);
tt = TOUT;

x = YOUT(:,1)';
y = YOUT(:,2)';
u = atan(tf - TOUT);

figure
subplot(2,1,1), plot( tt, x, 'b.-', tt, y, 'g+-'), xlabel('t'), legend('x','y')
title('Second Order System state variables');
subplot(2,1,2), plot( tt(1:end-1), u(1:end-1), 'b+-'), xlabel('t'), ylabel('u')
title('Second Order System control');


% plot(YOUT(:,1),YOUT(:,2))
% xlabel('x-axis')
% ylabel('y-axis')
% title('Trajectory, 1.1d)')